﻿using FwtXnaCommon.Scripts;
using FwtXnaGame3.Engine;
using FwtXnaGame3.Tools;
using GpgCore.GameWorld;
using Microsoft.Xna.Framework;

namespace GpgGame.GameObjects.MapItems
{
    public class VisualCity : VisualGameObject
    {
        public City City;

        public VisualCity(Scene scene, City city) : base(scene, null)
        {
            Sprite = GeneralFactory.CreateOnePxSprite(true);
            Transform2D.Color = Color.Brown;
            City = city;
        }

        public override void Start()
        {
            IsDrawServiceShadow = true;
            IsCheckMouseEvents = true;
            IsDrawGui = true;
            AddScript(new ButtonScript(this));
            Transform2D.Size = ParentGameObject2D.Transform2D.Size - new Vector2(2);
            base.Start();
        }

        public override void DrawGui()
        {
            var str = string.Format("{0}\r\n{1}", City.Name, City.Citizens.Population);
            SpriteBatch.DrawTextCenter(str, Transform2D.AbsolutePosition, Color.White, GodObject.CellInfoFont);
            base.DrawGui();
        }

        public override void MouseClickLeft()
        {
            GodObject.SelectedCity = City;
            base.MouseClickLeft();
        }
    }
}
